//
//  ByFootBallBottomView.m
//  caipiao_ios
//
//  Created by mc on 2018/7/20.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByFootBallBottomView.h"

@implementation ByFootBallBottomView

- (id)init{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        UIView *backgroundView = [[UIView alloc] init];
        [self addSubview:backgroundView];
        [backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(0);
            make.top.equalTo(self).offset(0);
            make.right.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
        }];
        
        UIButton *sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backgroundView addSubview:sureBtn];
        [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(backgroundView).offset(0);
            make.bottom.equalTo(backgroundView).offset(0);
            make.top.equalTo(backgroundView).offset(0);
            make.width.mas_equalTo(@140);
        }];
        sureBtn.backgroundColor = BY_THEME_COLOR;
        [sureBtn setTitle:@"确定" forState:UIControlStateNormal];
        [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        sureBtn.titleLabel.font = FONT(14);
        sureBtn.tag = 100;
        [sureBtn addTarget:self action:@selector(sureBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        
        UIButton *clearBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backgroundView addSubview:clearBtn];
        [clearBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(backgroundView).offset(0);
            make.left.equalTo(backgroundView).offset(16);
            make.size.mas_equalTo(CGSizeMake(22, 22));
        }];
        [clearBtn setImage:[UIImage imageNamed:@"shanchu删除"] forState:UIControlStateNormal];
        [clearBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        clearBtn.titleLabel.font = FONT(12);
        clearBtn.tag = 101;
        [clearBtn addTarget:self action:@selector(clearBtnAction:) forControlEvents:UIControlEventTouchUpInside];
       
        UILabel *countLabel = [[UILabel alloc] init];
        [backgroundView addSubview:countLabel];
        [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(clearBtn.mas_right).offset(5);
            make.top.equalTo(backgroundView).offset(7);
            make.right.equalTo(sureBtn.mas_left).offset(-10);
            make.height.mas_equalTo(@15);
        }];
        countLabel.text = @"已选0场比赛";
        countLabel.textColor = BY_TEXT_COLOR;
        countLabel.textAlignment = NSTextAlignmentRight;
        countLabel.font = FONT(13);
        self.countLabel = countLabel;
        
        UILabel *notesLabel = [[UILabel alloc] init];
        [backgroundView addSubview:notesLabel];
        [notesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(clearBtn.mas_right).offset(0);
            make.right.equalTo(sureBtn.mas_left).offset(0);
            make.bottom.equalTo(backgroundView).offset(-7);
            make.height.mas_equalTo(@15);
        }];
        notesLabel.textColor = [UIColor grayColor];
        notesLabel.font = FONT(12);
        notesLabel.text = @"页面赔率仅供参考，清以出票为准";
        notesLabel.textAlignment = NSTextAlignmentCenter;
        notesLabel.adjustsFontSizeToFitWidth = YES;
        
    }
    return self;
}

- (void)clearBtnAction:(UIButton *)btn{
    if (self.clearBlock) {
        self.clearBlock();
    }
}

- (void)sureBtnAction:(UIButton *)btn{
    if (self.sureBlock) {
        self.sureBlock();
    }
}

@end
